<meta charset="UTF-8">
<?php

include_once("../functions/db_manipulate.php");
if (!init()) {
  redirect('?action=login');
}

connectDB();
startTransaction();

$resultSet = mysql_query("DELETE FROM usrgroup WHERE userid='" . mysql_real_escape_string($_SESSION['id']) . "' AND groupid='" . mysql_real_escape_string($_GET['gid']) . "'") or die(mysql_error());

$initiatorAction = \controller\ControllerUtil::getEncodedActionFromUrlWithParameters($_SERVER['HTTP_REFERER']);

if ($resultSet) {
  commitTransaction();
  redirect("?action=msg&header=header.group.out.success&body=body.group.out.success&view=" . $initiatorAction);
} else {
  rollbackTransaction();
  redirect("?action=msg&header=header.group.out.failed&body=body.group.out.failed&view=" . $initiatorAction);
}
?>